package com.jyb.qiyefuwu.view.fragment.usercenter;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.jyb.qiyefuwu.R;
import com.jyb.qiyefuwu.databinding.FragmentNeedFollowParentBinding;
import com.jyb.qiyefuwu.uitls.CommPagerAdapter3;
import com.jyb.qiyefuwu.viewmodel.NeedFollowModel;
import com.swgk.core.base.AppLazyFragment;

import java.util.ArrayList;


/**
 * 作者:陈方凯
 * 日期:2020/09/17 0024
 * 说明:关注-需求大厅
 */
public class NeedFollowParentFragment extends AppLazyFragment {

    NeedFollowModel mModel;

    private FragmentNeedFollowParentBinding mBinding;
    private ArrayList<Fragment> mFragments = new ArrayList<>();
    private String[] type = new String[]{"全部", "商标", "专利", "版权", "服务"};
    private int index = 0;


    public static NeedFollowParentFragment newInstance(String position) {
        NeedFollowParentFragment fragment = new NeedFollowParentFragment();
        Bundle bundle = new Bundle();
        bundle.putString("data", position);
        fragment.setArguments(bundle);
        return fragment;
    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_need_follow_parent, container, false);
        return mBinding.getRoot();
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    protected void initView() {
        super.initView();
        addFragment();
    }

    private void addFragment() {
        mFragments.add(NeedFollowListFragment.newInstance(0));//全部
        mFragments.add(NeedFollowListFragment.newInstance(1));//商标
        mFragments.add(NeedFollowListFragment.newInstance(2));//专利
        mFragments.add(NeedFollowListFragment.newInstance(3));//版权
        mFragments.add(NeedFollowListFragment.newInstance(5));//服务
        CommPagerAdapter3 pagerAdapter = new CommPagerAdapter3(getChildFragmentManager(), mFragments, type);
        mBinding.viewpager.setOffscreenPageLimit(type.length);
        mBinding.viewpager.setAdapter(pagerAdapter);
        mBinding.tabLayout.setupWithViewPager(mBinding.viewpager);
        mBinding.tabLayout.getTabAt(index).select();
    }

    @Override
    protected void onLazyLoad() {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }
}